<%@page import="edu.boun.cmpe.elele.cotrans.dbOperations.DbOperations"%>
<%@page import="java.sql.SQLException"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <%
                String username = request.getParameter("username");
                String password = request.getParameter("password");

                DbOperations db = new DbOperations();
                out.println("Checking login<br>");
                if (db.checkLogin(username, password)) {
                    session.setAttribute("username", username);
                    session.setAttribute("userid", db.getUserID(username, password));
    %>
    <head>
        <meta http-equiv="REFRESH" content="0;url=./mainPage.jsp">
    <%
                    System.out.println("User db de var");
                    out.println("Welcome " + username + " <a href=\"mainPage.jsp\">Back to main</a>");

                } else {
                    out.println("Username or password does not exist.");
                    %>
          <meta http-equiv="REFRESH" content="2;url=./login.jsp">
    <%
                }
                db.getConn().close();

    %>
    </head>
</html>

